package com.ktjy.car.controller;

import com.ktjy.car.entity.Brand;
import com.ktjy.car.entity.vo.R;
import com.ktjy.car.service.BrandService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/api")
public class BrandController {
    
    @Resource
    private BrandService brandService;

    @GetMapping("/brands")
    public R getAllBrands() {
        try {
            List<Brand> brands = brandService.getFromCache();
            return R.ok(brands);
        } catch (Exception e) {
            e.printStackTrace();
            return R.fail("获取品牌列表失败：" + e.getMessage());
        }
    }
}